using System;
using System.Collections.Generic;
using System.Text;

namespace Nihonaid.classes.scheduler
{
    /// <summary>
    /// Implements the Pimsleur scheduling system
    /// </summary>
    public class PimsleurScheduler : IScheduler
    {
        private List<int> number_seconds;

        /// <summary>
        /// Constructs the scheduler
        /// </summary>
        public PimsleurScheduler()
        {
            this.number_seconds = new List<int>();
            LoadSchedulerData();
        }

        /// <summary>
        /// Loads the scheduler data
        /// </summary>
        public void LoadSchedulerData()
        {
            number_seconds.Add(0); // unused
            number_seconds.Add(5); // 5 seconds
            number_seconds.Add(25); // 25 seconds
            number_seconds.Add(2 * 60); // 2 minutes
            number_seconds.Add(10 * 60); // 10 minutes
            number_seconds.Add(1 * 60 * 60); // 1 hour
            number_seconds.Add(5 * 60 * 60); // 5 hours
            number_seconds.Add(24 * 60 * 60); // 24 hours
            number_seconds.Add(5 * 24 * 60 * 60); // 5 days
            number_seconds.Add(25 * 24 * 60 * 60); // 25 days
            number_seconds.Add(4 * 30 * 24 * 60 * 60); // 4 months
            number_seconds.Add(2 * 12 * 30 * 24 * 60 * 60); // 2 years
        }

        /// <summary>
        /// Returns the next scheduled repetition date
        /// </summary>
        /// <param name="number_successful_repetitions">Number of successful repetitions in a row</param>
        /// <returns>Next repetition date</returns>
        public DateTime GetNextDate(int number_successful_repetitions)
        {
            DateTime now = DateTime.Now;
            now = now.AddSeconds((double)number_seconds[number_successful_repetitions]);
            return now;
        }
    }
}